package com.wish233.wiliwilirelations.controller;

import com.wish233.wiliwiliapi.domain.dto.UserDTO;
import com.wish233.wiliwilicommon.common.BaseResponse;
import com.wish233.wiliwilicommon.common.ResultUtils;
import com.wish233.wiliwilicommon.exception.ThrowUtils;
import com.wish233.wiliwilirelations.domain.dto.FollowDTO;
import com.wish233.wiliwilirelations.domain.dto.FollowRequest;
import com.wish233.wiliwilirelations.service.FollowService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author WHH
 */
@RestController
@RequestMapping("/follow")
public class FollowController {

    @Resource
    private FollowService followService;

    @ApiOperation("关注，如果已经关注就取关")
    @PostMapping()
    public BaseResponse<Boolean> follow(@RequestBody FollowRequest followRequest) {
        ThrowUtils.throwIfParamNull(followRequest);
        return ResultUtils.success(followService.follow(followRequest));
    }

    @PostMapping("/list")
    @ApiOperation("查询一个用户所有的关注列表")
    public BaseResponse<List<UserDTO>> list() {
        return ResultUtils.success(followService.listNowUserFollowers());
    }
    @PostMapping("/fans")
    public BaseResponse<List<UserDTO>> getFans() {
        return ResultUtils.success(followService.getFans());

    }

}
